#include <iostream>

using namespace std;

int n;
double con[20][20];
double d[21][20][20], trace[21][20][20];

void traceStep(int step, int start, int end)
{
	if (step == 0)
	{
		cout << start+1;
		return;
	}
	traceStep(step-1, start, trace[step][start][end]);
	cout << " " << end+1;
}

int main()
{
	while (cin >> n)
	{
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++) 
				if (i == j) con[i][j] = 1.0;
				else cin >> con[i][j];		

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++) 
				d[1][i][j] = con[i][j];

		for (int step = 2; step <= n; step++)
		{
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < n; j++)
				{
					d[step][i][j] = -1000000000;
					for (int k = 0; k < n; k++) 
					{
						double temp = d[step-1][i][k] * con[k][j];
						if (d[step][i][j] < temp)
						{	
							d[step][i][j] = temp;
							trace[step][i][j] = k;
						}
					}
				}
				if (d[step][i][i] > 1.01)
				{
					traceStep(step, i, i);
					cout << endl;
					goto label;
				}
			}
		}
		cout << "no arbitrage sequence exists" << endl;

		label: {}	
	}
	
	return 0;
}
